#include "Matrix3x3.h"

/*Matrix3x3::Matrix3x3()
{
}

Matrix3x3::Matrix3x3(double New_x1, double New_y1, double New_z1, double New_x2, double New_y2, double New_z2, double New_x3, double New_y3, double New_z3)
{
    a.x = New_x1;   b.x = New_x2;   c.x = New_x3;
    a.y = New_y1;   b.y = New_y2;   c.y = New_y3;
    a.z = New_z1;   b.z = New_z2;   c.z = New_z3;
}

Matrix3x3::Matrix3x3(double *New_x1, double *New_y1, double *New_z1, double *New_x2, double *New_y2, double *New_z2, double *New_x3, double *New_y3, double *New_z3)
{
    a.x = *New_x1;   b.x = *New_x2;   c.x = *New_x3;
    a.y = *New_y1;   b.y = *New_y2;   c.y = *New_y3;
    a.z = *New_z1;   b.z = *New_z2;   c.z = *New_z3;
}

Matrix3x3::Matrix3x3(Vector3 V1, Vector3 V2, Vector3 V3)
{
    a = V1;
    b = V2;
    c = V3;
}

Matrix3x3::Matrix3x3(Vector3 *V1, Vector3 V2, Vector3 V3)
{
    a = *V1;
    b = V2;
    c = V3;
}

Matrix3x3::Matrix3x3(Vector3 V1, Vector3 *V2, Vector3 V3)
{
    a = V1;
    b = *V2;
    c = V3;
}

Matrix3x3::Matrix3x3(Vector3 V1, Vector3 V2, Vector3 *V3)
{
    a = V1;
    b = V2;
    c = *V3;
}
Matrix3x3::Matrix3x3(Vector3 V1, Vector3 *V2, Vector3 *V3)
{
    a = V1;
    b = *V2;
    c = *V3;
}

Matrix3x3::Matrix3x3(Vector3 *V1, Vector3 V2, Vector3 *V3)
{
    a = *V1;
    b = V2;
    c = *V3;
}

Matrix3x3::Matrix3x3(Vector3 *V1, Vector3 *V2, Vector3 V3)
{
    a = *V1;
    b = *V2;
    c = V3;
}

Matrix3x3::Matrix3x3(Vector3 *V1, Vector3 *V2, Vector3 *V3)
{
    a = *V1;
    b = *V2;
    c = *V3;
}

Matrix3x3::Matrix3x3(Matrix3x3 *New_Matrix3x3)
{
    *this=*New_Matrix3x3;
}

Matrix3x3::Matrix3x3(Vector3 New_A, Vector3 New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a = New_A;
    b = New_B;
    c.set(New_Cx, New_Cy, New_Cz);
}

Matrix3x3::Matrix3x3(Vector3 *New_A, Vector3 New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a = *New_A;
    b = New_B;
    c.set(New_Cx, New_Cy, New_Cz);
}

Matrix3x3::Matrix3x3(Vector3 New_A, Vector3 *New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a = New_A;
    b = *New_B;
    c.set(New_Cx, New_Cy, New_Cz);
}

Matrix3x3::Matrix3x3(Vector3 *New_A, Vector3 *New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a = *New_A;
    b = *New_B;
    c.set(New_Cx, New_Cy, New_Cz);
}

Matrix3x3::Matrix3x3(Vector3 New_A,  double New_Bx, double New_By, double New_Bz, Vector3 New_C)
{
    a = New_A;
    b.set(New_Bx, New_By, New_Bz);
    c = New_C;
}

Matrix3x3::Matrix3x3(Vector3 *New_A,  double New_Bx, double New_By, double New_Bz, Vector3 New_C)
{
    a = *New_A;
    b.set(New_Bx, New_By, New_Bz);
    c = New_C;
}

Matrix3x3::Matrix3x3(Vector3 New_A,  double New_Bx, double New_By, double New_Bz, Vector3 *New_C)
{
    a = New_A;
    b.set(New_Bx, New_By, New_Bz);
    c = *New_C;
}

Matrix3x3::Matrix3x3(Vector3 *New_A,  double New_Bx, double New_By, double New_Bz, Vector3 *New_C)
{
    a = *New_A;
    b.set(New_Bx, New_By, New_Bz);
    c = New_C;
}


Matrix3x3::Matrix3x3(double New_Ax, double New_Ay, double New_Az, Vector3 New_B, Vector3 New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = New_B;
    c = New_C;
}

Matrix3x3::Matrix3x3(double New_Ax, double New_Ay, double New_Az, Vector3 *New_B, Vector3 New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = *New_B;
    c = New_C;
}

Matrix3x3::Matrix3x3(double New_Ax, double New_Ay, double New_Az, Vector3 New_B, Vector3 *New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = New_B;
    c = *New_C;
}

Matrix3x3::Matrix3x3(double New_Ax, double New_Ay, double New_Az, Vector3 *New_B, Vector3 *New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = *New_B;
    c = *New_C;
}


Matrix3x3::Matrix3x3(Vector3 New_A, double New_Bx, double New_By, double New_Bz, double New_Cx, double New_Cy, double New_Cz)
{
    a = New_A;
    b.set(New_Bx, New_By, New_Bz);
    c.set(New_Cx, New_Cy, New_Cz);
}
Matrix3x3::Matrix3x3(Vector3 *New_A, double New_Bx, double New_By, double New_Bz, double New_Cx, double New_Cy, double New_Cz)
{
    a = *New_A;
    b.set(New_Bx, New_By, New_Bz);
    c.set(New_Cx, New_Cy, New_Cz);
}

Matrix3x3::Matrix3x3(double New_Ax, double New_Ay, double New_Az, Vector3 New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = New_B;
    c.set(New_Cx, New_Cy, New_Cz);
}

Matrix3x3::Matrix3x3(double New_Ax, double New_Ay, double New_Az, Vector3 *New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = *New_B;
    c.set(New_Cx, New_Cy, New_Cz);
}


Matrix3x3::Matrix3x3(double New_Ax, double New_Ay, double New_Az, double New_Bx, double New_By, double New_Bz, Vector3 New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b.set(New_Bx, New_By, New_Bz);
    c = New_C;
}

Matrix3x3::Matrix3x3(double New_Ax, double New_Ay, double New_Az, double New_Bx, double New_By, double New_Bz, Vector3 *New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b.set(New_Bx, New_By, New_Bz);
    c = *New_C;
}*/

/*Matrix3x3 Matrix3x3::set(double New_x1, double New_y1, double New_z1, double New_x2, double New_y2, double New_z2, double New_x3, double New_y3, double New_z3)
{
    a.x = New_x1;   b.x = New_x2;   c.x = New_x3;
    a.y = New_y1;   b.y = New_y2;   c.y = New_y3;
    a.z = New_z1;   b.z = New_z2;   c.z = New_z3;

    return *this;
}

Matrix3x3 Matrix3x3::set(double *New_x1, double *New_y1, double *New_z1, double *New_x2, double *New_y2, double *New_z2, double *New_x3, double *New_y3, double *New_z3)
{
    a.x = *New_x1;   b.x = *New_x2;   c.x = *New_x3;
    a.y = *New_y1;   b.y = *New_y2;   c.y = *New_y3;
    a.z = *New_z1;   b.z = *New_z2;   c.z = *New_z3;

    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 V1, Vector3 V2, Vector3 V3)
{
    a = V1;
    b = V2;
    c = V3;

    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 *V1, Vector3 V2, Vector3 V3)
{
    a = *V1;
    b = V2;
    c = V3;

    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 V1, Vector3 *V2, Vector3 V3)
{
    a = V1;
    b = *V2;
    c = V3;

    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 V1, Vector3 V2, Vector3 *V3)
{
    a = V1;
    b = V2;
    c = *V3;

    return *this;
}
Matrix3x3 Matrix3x3::set(Vector3 V1, Vector3 *V2, Vector3 *V3)
{
    a = V1;
    b = *V2;
    c = *V3;

    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 *V1, Vector3 V2, Vector3 *V3)
{
    a = *V1;
    b = V2;
    c = *V3;

    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 *V1, Vector3 *V2, Vector3 V3)
{
    a = *V1;
    b = *V2;
    c = V3;

    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 *V1, Vector3 *V2, Vector3 *V3)
{
    a = *V1;
    b = *V2;
    c = *V3;

    return *this;
}


Matrix3x3 Matrix3x3::set(Vector3 New_A, Vector3 New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a = New_A;
    b = New_B;
    c.set(New_Cx, New_Cy, New_Cz);
    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 *New_A, Vector3 New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a = *New_A;
    b = New_B;
    c.set(New_Cx, New_Cy, New_Cz);
    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 New_A, Vector3 *New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a = New_A;
    b = *New_B;
    c.set(New_Cx, New_Cy, New_Cz);
    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 *New_A, Vector3 *New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a = *New_A;
    b = *New_B;
    c.set(New_Cx, New_Cy, New_Cz);
    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 New_A,  double New_Bx, double New_By, double New_Bz, Vector3 New_C)
{
    a = New_A;
    b.set(New_Bx, New_By, New_Bz);
    c = New_C;
    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 *New_A,  double New_Bx, double New_By, double New_Bz, Vector3 New_C)
{
    a = *New_A;
    b.set(New_Bx, New_By, New_Bz);
    c = New_C;
    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 New_A,  double New_Bx, double New_By, double New_Bz, Vector3 *New_C)
{
    a = New_A;
    b.set(New_Bx, New_By, New_Bz);
    c = *New_C;
    return *this;
}

Matrix3x3 Matrix3x3::set(Vector3 *New_A,  double New_Bx, double New_By, double New_Bz, Vector3 *New_C)
{
    a = *New_A;
    b.set(New_Bx, New_By, New_Bz);
    c = New_C;
    return *this;
}


Matrix3x3 Matrix3x3::set(double New_Ax, double New_Ay, double New_Az, Vector3 New_B, Vector3 New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = New_B;
    c = New_C;
    return *this;
}

Matrix3x3 Matrix3x3::set(double New_Ax, double New_Ay, double New_Az, Vector3 *New_B, Vector3 New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = *New_B;
    c = New_C;
    return *this;
}

Matrix3x3 Matrix3x3::set(double New_Ax, double New_Ay, double New_Az, Vector3 New_B, Vector3 *New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = New_B;
    c = *New_C;
    return *this;
}

Matrix3x3 Matrix3x3::set(double New_Ax, double New_Ay, double New_Az, Vector3 *New_B, Vector3 *New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = *New_B;
    c = *New_C;
    return *this;
}


Matrix3x3 Matrix3x3::set(Vector3 New_A, double New_Bx, double New_By, double New_Bz, double New_Cx, double New_Cy, double New_Cz)
{
    a = New_A;
    b.set(New_Bx, New_By, New_Bz);
    c.set(New_Cx, New_Cy, New_Cz);
    return *this;
}
Matrix3x3 Matrix3x3::set(Vector3 *New_A, double New_Bx, double New_By, double New_Bz, double New_Cx, double New_Cy, double New_Cz)
{
    a = *New_A;
    b.set(New_Bx, New_By, New_Bz);
    c.set(New_Cx, New_Cy, New_Cz);
    return *this;
}

Matrix3x3 Matrix3x3::set(double New_Ax, double New_Ay, double New_Az, Vector3 New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = New_B;
    c.set(New_Cx, New_Cy, New_Cz);
    return *this;
}

Matrix3x3 Matrix3x3::set(double New_Ax, double New_Ay, double New_Az, Vector3 *New_B, double New_Cx, double New_Cy, double New_Cz)
{
    a.set(New_Ax, New_Ay, New_Az);
    b = *New_B;
    c.set(New_Cx, New_Cy, New_Cz);
    return *this;
}


Matrix3x3 Matrix3x3::set(double New_Ax, double New_Ay, double New_Az, double New_Bx, double New_By, double New_Bz, Vector3 New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b.set(New_Bx, New_By, New_Bz);
    c = New_C;
    return *this;
}

Matrix3x3 Matrix3x3::set(double New_Ax, double New_Ay, double New_Az, double New_Bx, double New_By, double New_Bz, Vector3 *New_C)
{
    a.set(New_Ax, New_Ay, New_Az);
    b.set(New_Bx, New_By, New_Bz);
    c = *New_C;
    return *this;
}*/

/*Vector3 Vector3::rotateGrad(double x, double y, double z)
{
    double X = pi * x / 180;
    double Y = pi * y / 180;
    double Z = pi * z / 180;

    Vector3 V2(this);

    Matrix3x3 Mx(1.0,     0.0,      0.0,
                 0.0, cos(X),-sin(X),
                 0.0, sin(X), cos(X));

    Matrix3x3 My( cos(Y),   0,  sin(Y),
                       0,   1,      0,
                 -sin(Y),   0,  cos(Y));

    Matrix3x3 Mz( cos(Z),-sin(Z),    0,
                  sin(Z), cos(Z),    0,
                      0,      0,     1);

    *this = Mz * (My * (Mx * V2));
    return *this;
}

Vector3 rotateGrad(Vector3 V, double x, double y, double z)
{
    double X = pi * x / 180;
    double Y = pi * y / 180;
    double Z = pi * z / 180;

    Matrix3x3 Mx(1.0,     0.0,      0.0,
                 0.0, cos(X),-sin(X),
                 0.0, sin(X), cos(X));

    Matrix3x3 My( cos(Y),   0,  sin(Y),
                       0,   1,      0,
                 -sin(Y),   0,  cos(Y));

    Matrix3x3 Mz( cos(Z),-sin(Z),    0,
                  sin(Z), cos(Z),    0,
                      0,      0,     1);

    return Mz * (My * (Mx * V));
}
Vector3 Vector3::rotateRad(double x, double y, double z)
{
    Vector3 V2(this);

    Matrix3x3 Mx(1.0,     0.0,      0.0,
                 0.0, cos(x),-sin(x),
                 0.0, sin(x), cos(x));

    Matrix3x3 My( cos(y),   0,  sin(y),
                       0,   1,      0,
                 -sin(y),   0,  cos(y));

    Matrix3x3 Mz( cos(z),-sin(z),    0,
                  sin(z), cos(z),    0,
                      0,      0,     1);

    *this = Mz * (My * (Mx * V2));
    return *this;
}
Vector3 rotateRad(Vector3 V, double x, double y, double z)
{
    Matrix3x3 Mx(1.0,     0.0,      0.0,
                 0.0, cos(x),-sin(x),
                 0.0, sin(x), cos(x));

    Matrix3x3 My( cos(y),   0,  sin(y),
                       0,   1,      0,
                 -sin(y),   0,  cos(y));

    Matrix3x3 Mz( cos(z),-sin(z),    0,
                  sin(z), cos(z),    0,
                      0,      0,     1);

    return Mz * (My * (Mx * V));
}*/

Matrix3x3 Matrix3x3::operator = (Matrix3x3 M)
{
    a = M.a;
    b = M.b;
    c = M.c;

    return *this;
}

/*Matrix3x3 Matrix3x3::operator = (Matrix3x3 *M)
{
    a = M->a;
    b = M->b;
    c = M->c;

    return *this;
}*/

Matrix3x3 Matrix3x3::operator += (Matrix3x3 M)
{
    a = a + M.a;
    b = b + M.b;
    c = c + M.c;

    return *this;
}

/*Matrix3x3 Matrix3x3::operator += (Matrix3x3 *M)
{
    a = a + M->a;
    b = b + M->b;
    c = c + M->c;

    return *this;
}*/

Matrix3x3 Matrix3x3::operator -= (Matrix3x3 M)
{
    a = a - M.a;
    b = b - M.b;
    c = c - M.c;

    return *this;
}

/*Matrix3x3 Matrix3x3::operator -= (Matrix3x3 *M)
{
    a = a - M->a;
    b = b - M->b;
    c = c - M->c;

    return *this;
}*/

Matrix3x3 Matrix3x3::operator *= (Matrix3x3 M)
{
    a.set(a.getX() * M.getAX() + a.getY() * M.getBX() + a.getZ() * M.getCX(), a.getX() * M.getAY() + a.getY() * M.getBY() + a.getZ() * M.getCY(), a.getX() * M.getAZ() + a.getY() * M.getBZ() + a.getZ() * M.getCZ());
    b.set(b.getX() * M.getAX() + b.getY() * M.getBX() + b.getZ() * M.getCX(), b.getX() * M.getAY() + b.getY() * M.getBY() + b.getZ() * M.getCY(), b.getX() * M.getAZ() + b.getY() * M.getBZ() + b.getZ() * M.getCZ());
    c.set(c.getX() * M.getAX() + c.getY() * M.getBX() + c.getZ() * M.getCX(), c.getX() * M.getAY() + c.getY() * M.getBY() + c.getZ() * M.getCY(), c.getX() * M.getAZ() + c.getY() * M.getBZ() + c.getZ() * M.getCZ());
    //a.x = a.x * M.getAX() + a.y * M.getBX() + a.z * M.getCX();   a.y = a.x * M.getAY() + a.y * M.getBY() + a.z * M.getCY();  a.z = a.x * M.getAZ() + a.y * M.getBZ() + a.z * M.getCZ();
    //b.x = b.x * M.getAX() + b.y * M.getBX() + b.z * M.getCX();   b.y = b.x * M.getAY() + b.y * M.getBY() + b.z * M.getCY();  b.z = b.x * M.getAZ() + b.y * M.getBZ() + b.z * M.getCZ();
    //c.x = c.x * M.getAX() + c.y * M.getBX() + c.z * M.getCX();   c.y = c.x * M.getAY() + c.y * M.getBY() + c.z * M.getCY();  c.z = c.x * M.getAZ() + c.y * M.getBZ() + c.z * M.getCZ();

    return *this;
}

/*Matrix3x3 Matrix3x3::operator *= (Matrix3x3 *M)
{
    a.x = a.x * M->a.x + a.y * M->b.x + a.z * M->c.x;   a.y = a.x * M->a.y + a.y * M->b.y + a.z * M->c.y;  a.z = a.x * M->a.z + a.y * M->b.z + a.z * M->c.z;
    b.x = b.x * M->a.x + b.y * M->b.x + b.z * M->c.x;   b.y = b.x * M->a.y + b.y * M->b.y + b.z * M->c.y;  b.z = b.x * M->a.z + b.y * M->b.z + b.z * M->c.z;
    c.x = c.x * M->a.x + c.y * M->b.x + c.z * M->c.x;   c.y = c.x * M->a.y + c.y * M->b.y + c.z * M->c.y;  c.z = c.x * M->a.z + c.y * M->b.z + c.z * M->c.z;

    return *this;
}*/

Matrix3x3 Matrix3x3::operator *= (double R)
{
    a *= R;
    b *= R;
    c *= R;
    //a.x = a.x * R;   a.y = a.y * R;  a.z = a.z * R;
    //b.x = b.x * R;   b.y = b.y * R;  b.z = b.z * R;
    //c.x = c.x * R;   c.y = c.y * R;  c.z = c.z * R;

    return *this;
}

/*Matrix3x3 Matrix3x3::operator *= (double *R)
{
    a.x = a.x * *R;   a.y = a.y * *R;  a.z = a.z * *R;
    b.x = b.x * *R;   b.y = b.y * *R;  b.z = b.z * *R;
    c.x = c.x * *R;   c.y = c.y * *R;  c.z = c.z * *R;

    return *this;
}*/

Matrix3x3 Matrix3x3::operator /= (double R)
{
    a /= R;
    b /= R;
    c /= R;
    //a.x = a.x / R;   a.y = a.y / R;  a.z = a.z / R;
    //b.x = b.x / R;   b.y = b.y / R;  b.z = b.z / R;
    //c.x = c.x / R;   c.y = c.y / R;  c.z = c.z / R;

    return *this;
}

/*Matrix3x3 Matrix3x3::operator /= (double *R)
{
    a.x = a.x / *R;   a.y = a.y / *R;  a.z = a.z / *R;
    b.x = b.x / *R;   b.y = b.y / *R;  b.z = b.z / *R;
    c.x = c.x / *R;   c.y = c.y / *R;  c.z = c.z / *R;

    return *this;
}*/

Matrix3x3 Matrix3x3::operator + (Matrix3x3 M)
{
    /*Matrix3x3 res;
    res.a = a + M.a;
    res.b = b + M.b;
    res.c = c + M.c;
*/
    return Matrix3x3(a + M.a, b + M.b, c + M.c);
}
/*Matrix3x3 Matrix3x3::operator + (Matrix3x3 *M)
{
    Matrix3x3 res;
    res.a = a + M->a;
    res.b = b + M->b;
    res.c = c + M->c;

    return res;
}*/
Matrix3x3 Matrix3x3::operator - (Matrix3x3 M)
{
    /*Matrix3x3 res;
    res.a = a - M.a;
    res.b = b - M.b;
    res.c = c - M.c;
*/
    return Matrix3x3(a - M.a, b - M.b, c - M.c);
}
/*Matrix3x3 Matrix3x3::operator - (Matrix3x3 *M)
{
    Matrix3x3 res;
    res.a = a - M->a;
    res.b = b - M->b;
    res.c = c - M->c;

    return res;
}*/

Matrix3x3 Matrix3x3::operator * (Matrix3x3 M)
{
    /*a.set(a.getX() * M.getAX() + a.getY() * M.getBX() + a.getZ() * M.getCX(), a.getX() * M.getAY() + a.getY() * M.getBY() + a.getZ() * M.getCY(), a.getX() * M.getAZ() + a.getY() * M.getBZ() + a.getZ() * M.getCZ());
    b.set(b.getX() * M.getAX() + b.getY() * M.getBX() + b.getZ() * M.getCX(), b.getX() * M.getAY() + b.getY() * M.getBY() + b.getZ() * M.getCY(), b.getX() * M.getAZ() + b.getY() * M.getBZ() + b.getZ() * M.getCZ());
    c.set(c.getX() * M.getAX() + c.getY() * M.getBX() + c.getZ() * M.getCX(), c.getX() * M.getAY() + c.getY() * M.getBY() + c.getZ() * M.getCY(), c.getX() * M.getAZ() + c.getY() * M.getBZ() + c.getZ() * M.getCZ());

    Matrix3x3 res;
    res.a.x = a.x * M.a.x + a.y * M.b.x + a.z * M.c.x;   res.a.y = a.x * M.a.y + a.y * M.b.y + a.z * M.c.y;  res.a.z = a.x * M.a.z + a.y * M.b.z + a.z * M.c.z;
    res.b.x = b.x * M.a.x + b.y * M.b.x + b.z * M.c.x;   res.b.y = b.x * M.a.y + b.y * M.b.y + b.z * M.c.y;  res.b.z = b.x * M.a.z + b.y * M.b.z + b.z * M.c.z;
    res.c.x = c.x * M.a.x + c.y * M.b.x + c.z * M.c.x;   res.c.y = c.x * M.a.y + c.y * M.b.y + c.z * M.c.y;  res.c.z = c.x * M.a.z + c.y * M.b.z + c.z * M.c.z;
*/
    return Matrix3x3(a.getX() * M.getAX() + a.getY() * M.getBX() + a.getZ() * M.getCX(), a.getX() * M.getAY() + a.getY() * M.getBY() + a.getZ() * M.getCY(), a.getX() * M.getAZ() + a.getY() * M.getBZ() + a.getZ() * M.getCZ(),
                     b.getX() * M.getAX() + b.getY() * M.getBX() + b.getZ() * M.getCX(), b.getX() * M.getAY() + b.getY() * M.getBY() + b.getZ() * M.getCY(), b.getX() * M.getAZ() + b.getY() * M.getBZ() + b.getZ() * M.getCZ(),
                     c.getX() * M.getAX() + c.getY() * M.getBX() + c.getZ() * M.getCX(), c.getX() * M.getAY() + c.getY() * M.getBY() + c.getZ() * M.getCY(), c.getX() * M.getAZ() + c.getY() * M.getBZ() + c.getZ() * M.getCZ());
}
/*Matrix3x3 Matrix3x3::operator * (Matrix3x3 *M)
{
    Matrix3x3 res;
    res.a.x = a.x * M->a.x + a.y * M->b.x + a.z * M->c.x;   res.a.y = a.x * M->a.y + a.y * M->b.y + a.z * M->c.y;  res.a.z = a.x * M->a.z + a.y * M->b.z + a.z * M->c.z;
    res.b.x = b.x * M->a.x + b.y * M->b.x + b.z * M->c.x;   res.b.y = b.x * M->a.y + b.y * M->b.y + b.z * M->c.y;  res.b.z = b.x * M->a.z + b.y * M->b.z + b.z * M->c.z;
    res.c.x = c.x * M->a.x + c.y * M->b.x + c.z * M->c.x;   res.c.y = c.x * M->a.y + c.y * M->b.y + c.z * M->c.y;  res.c.z = c.x * M->a.z + c.y * M->b.z + c.z * M->c.z;

    return res;
}*/
Vector3 Matrix3x3::operator * (Vector3 V)
{
    /*Vector3 res;
    res.x = a % V;
    res.y = b % V;
    res.z = c % V;
*/
    return Vector3(a % V, b % V, c % V);
}

/*Vector3 Matrix3x3::operator * (Vector3 *V)
{
    Vector3 res;
    res.x = a % *V;
    res.y = b % *V;
    res.z = c % *V;

    return res;
}*/
Matrix3x3 Matrix3x3::operator * (double R)
{
    /*Matrix3x3 res;
    res.a.x = a.x * R;   res.a.y = a.y * R;  res.a.z = a.z * R;
    res.b.x = b.x * R;   res.b.y = b.y * R;  res.b.z = b.z * R;
    res.c.x = c.x * R;   res.c.y = c.y * R;  res.c.z = c.z * R;
*/
    return Matrix3x3(a * R, b * R, c * R);
}

/*Matrix3x3 Matrix3x3::operator * (double *R)
{
    Matrix3x3 res;
    res.a.x = a.x * *R;   res.a.y = a.y * *R;  res.a.z = a.z * *R;
    res.b.x = b.x * *R;   res.b.y = b.y * *R;  res.b.z = b.z * *R;
    res.c.x = c.x * *R;   res.c.y = c.y * *R;  res.c.z = c.z * *R;

    return res;
}*/

Matrix3x3 Matrix3x3::operator / (double R)
{
    /*Matrix3x3 res;
    a.x = a.x / R;   a.y = a.y / R;  a.z = a.z / R;
    b.x = b.x / R;   b.y = b.y / R;  b.z = b.z / R;
    c.x = c.x / R;   c.y = c.y / R;  c.z = c.z / R;
    */
    return Matrix3x3(a / R, b / R, c / R);
}

/*Matrix3x3 Matrix3x3::operator / (double *R)
{
    Matrix3x3 res;
    res.a.x = a.x / *R;   res.a.y = a.y / *R;  res.a.z = a.z / *R;
    res.b.x = b.x / *R;   res.b.y = b.y / *R;  res.b.z = b.z / *R;
    res.c.x = c.x / *R;   res.c.y = c.y / *R;  res.c.z = c.z / *R;

    return res;
}*/

int Matrix3x3::operator == (Matrix3x3 M)
{
    /*if (a.x==M.a.x && a.y==M.a.y && a.z==M.a.z &&
        b.x==M.b.x && b.y==M.b.y && b.z==M.b.z &&
        c.x==M.c.x && c.y==M.c.y && c.z==M.c.z)
    return 1;*/
    return a == M.getA() && b == M.getB() && c == M.getC();
}
/*int Matrix3x3::operator == (Matrix3x3 *M)
{
    if (a.x==M->a.x && a.y==M->a.y && a.z==M->a.z &&
        b.x==M->b.x && b.y==M->b.y && b.z==M->b.z &&
        c.x==M->c.x && c.y==M->c.y && c.z==M->c.z)
    return 1;
    return 0;

}*/

int Matrix3x3::operator != (Matrix3x3 M)
{
    /*if (a.x==M.a.x && a.y==M.a.y && a.z==M.a.z &&
        b.x==M.b.x && b.y==M.b.y && b.z==M.b.z &&
        c.x==M.c.x && c.y==M.c.y && c.z==M.c.z)
    return 0;*/
    return (a != M.getA()) + (b != M.getB()) + (c != M.getC());
}

/*int Matrix3x3::operator != (Matrix3x3 *M)
{
    if (a.x==M->a.x && a.y==M->a.y && a.z==M->a.z &&
        b.x==M->b.x && b.y==M->b.y && b.z==M->b.z &&
        c.x==M->c.x && c.y==M->c.y && c.z==M->c.z)
    return 0;
    return 1;
}*/

Matrix3x3 Matrix3x3::setRotationMatrix(Vector3 V, double R)
{
    /*Matrix3x3 i(1, 0, 0,
                0, 1, 0,
                0, 0, 1);*/
    /*i.a.x = 1;   i.a.y = 0;  i.a.z = 0;
    i.b.x = 0;   i.b.y = 1;  i.b.z = 0;
    i.c.x = 0;   i.c.y = 0;  i.c.z = 1;
*/
    Matrix3x3 s(0,         V.getZ(),  -V.getY(),
                -V.getZ(), 0,         V.getX(),
                V.getY(),  -V.getX(), 0);
    /*s.a.x =    0;   s.a.y =  V.z;  s.a.z = -V.y;
    s.b.x = -V.z;   s.b.y =    0;  s.b.z =  V.x;
    s.c.x =  V.y;   s.c.y = -V.x;  s.c.z =    0;
*/
    *this = Matrix3x3 (1, 0, 0, 0, 1, 0, 0, 0, 1) + ((s * sin(R)) + ((s * s) * (1 - cos(R))));
    return *this;
}

Matrix3x3 makeRotationMatrix(Vector3 V, double R)
{
    /*Matrix3x3 i, s;
    i.a.x = 1;   i.a.y = 0;  i.a.z = 0;
    i.b.x = 0;   i.b.y = 1;  i.b.z = 0;
    i.c.x = 0;   i.c.y = 0;  i.c.z = 1;

    s.a.x =    0;   s.a.y =  V.z;  s.a.z = -V.y;
    s.b.x = -V.z;   s.b.y =    0;  s.b.z =  V.x;
    s.c.x =  V.y;   s.c.y = -V.x;  s.c.z =    0;
    */
    Matrix3x3 s(0,         V.getZ(),  -V.getY(),
                -V.getZ(), 0,         V.getX(),
                V.getY(),  -V.getX(), 0);

    return Matrix3x3 (1, 0, 0, 0, 1, 0, 0, 0, 1) + ((s * sin(R)) + ((s * s) * (1 - cos(R))));
}

double Matrix3x3::getMatrixDeterminant(Matrix3x3 M)
{
    return M.getAX() * M.getBY() * M.getCZ() + M.getBX() * M.getCY() * M.getAZ() + M.getCX() * M.getAY() * M.getBZ() - M.getCX() * M.getBY() * M.getAZ() - M.getAX() * M.getCY() * M.getBZ() - M.getBX() * M.getAY() * M.getCZ();
}
